<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sd" uri="/struts-dojo-tags" %>


<script type="text/javascript" src="<s:url value="/js/teachingCommittee.js"/>"></script>

<sd:head parseContent="true"/>

<s:form id="formEdit" cssClass="tableEdit">
    <s:hidden name="id" value="%{comiteDocencia.id}"/>
    <s:hidden name="comiteDocencia.id" value="%{comiteDocencia.id}"/>
    <s:hidden name="address.id" value="%{comiteDocencia.address.id}"/>

    <s:textfield label="Name" name="name" value="%{comiteDocencia.name}"/>
    <s:textfield label="Agree Receiving Directly From Sponsor" name="agreeReceivingDirectlyFromSponsor" value="%{comiteDocencia.agreeReceivingDirectlyFromSponsor}"/>
    <s:textfield label="Document Approval Delay" name="documentApprovalDelay" value="%{comiteDocencia.documentApprovalDelay}"/>
    <s:textfield label="How Often They Met" name="howOftenTheyMet" value="%{comiteDocencia.howOftenTheyMet}"/>
    <s:textfield label="List Of Members Not Participating" name="listOfMembersNotParticipating" value="%{comiteDocencia.listOfMembersNotParticipating}"/>
    <s:textfield label="List Of Members Participating" name="listOfMembersParticipating" value="%{comiteDocencia.listOfMembersParticipating}"/>
    <s:textfield label="Need Ecapproval" name="needEcapproval" value="%{comiteDocencia.needEcapproval}"/>
    <s:textfield label="Timeline To Submit" name="timelineToSubmit" value="%{comiteDocencia.timelineToSubmit}"/>
    <s:select label="Center" name="comiteDocencia.centro.id" id="center"
              headerKey="-1" headerValue="None"
              list="centers"
              listKey="id"
              listValue="corporateName"
              value="comiteDocencia.centro.id">
    </s:select>
    <sd:datetimepicker
            label="Next Meeting" name="nextMeeting"
            value="%{comiteDocencia.nextMeeting}" displayFormat="dd/MM/yyyy"
    />

    <s:textfield label="Address" name="address.address" value="%{comiteDocencia.address.address}"/>

    <s:hidden label="City" name="address.city" id="addressCity" value="%{comiteDocencia.address.city}"/>
    <s:hidden label="Province" name="address.province" id="addressProvince" value="%{comiteDocencia.address.province}"/>
    <s:hidden label="Country" name="address.country" id="addressCountry" value="%{comiteDocencia.address.country}"/>

    <s:if test="%{comiteDocencia.id != null}">
        <s:include value="../address/addressedit.jsp"/>
    </s:if>
    <s:else>
        <s:include value="../address/addressview.jsp"/>
    </s:else>



    <TABLE id="table_content" width="350px" >
        <thead>
        <TR>
            <th>Name</th>
            <th>Surname</th>
            <th>Role</th>
            <th>Degree</th>
            <th>email</th>
            <th>Fax</th>
            <th>Phone</th>
        </TR>
        </thead>
        <tbody>
        <s:if test="%{comiteDocencia.id == null || comiteDocencia.contactPersons.isEmpty()}">
            <TR>
                <TH><s:textfield name="comiteDocencia.contactPersons[0].name" value="%{comiteDocencia.contactPersons[0].name}" theme="simple" cssClass="required"/></TH>
                <TH><s:textfield name="comiteDocencia.contactPersons[0].surname" value="%{comiteDocencia.contactPersons[0].surname}" theme="simple" cssClass="required"/></TH>
                <TH>
                    <s:select label="Role" name="comiteDocencia.contactPersons[0].role.id" id="role"
                              headerKey="" headerValue="Choose a Role"
                              list="roles"
                              listKey="id"
                              listValue="descripcion"
                              value="%{comiteDocencia.contactPersons[0].role.id}"
                              cssClass="required"
                              theme="simple">
                    </s:select>
                </TH>
                <TH><s:textfield name="comiteDocencia.contactPersons[0].degree" value="%{comiteDocencia.contactPersons[0].degree}" theme="simple" cssClass="required"/></TH>
                <TH><s:textfield name="comiteDocencia.contactPersons[0].email" value="%{comiteDocencia.contactPersons[0].email}" theme="simple" cssClass="required"/></TH>
                <TH><s:textfield name="comiteDocencia.contactPersons[0].fax" value="%{comiteDocencia.contactPersons[0].fax}" theme="simple" cssClass="required"/></TH>
                <TH><s:textfield name="comiteDocencia.contactPersons[0].phone" value="%{comiteDocencia.contactPersons[0].phone}" theme="simple" cssClass="required"/></TH>
                <TH><a onclick="deleteRow('table_content', this)"><img src="<s:url value="/images/delete2.png"/>" alt="Delete"></a></TH>
            </TR>
        </s:if>
        <s:else>
            <s:iterator value="%{comiteDocencia.contactPersons}"  status="stat">
                <TR>
                    <TH><s:textfield name="comiteDocencia.contactPersons[%{#stat.index}].name" value="%{comiteDocencia.contactPersons[#stat.index].name}" theme="simple" cssClass="required"/></TH>
                    <TH><s:textfield name="comiteDocencia.contactPersons[%{#stat.index}].surname" value="%{comiteDocencia.contactPersons[#stat.index].surname}" theme="simple" cssClass="required"/></TH>
                    <TH>
                        <s:select label="Role" name="comiteDocencia.contactPersons[%{#stat.index}].role.id" id="role"
                                  headerKey="" headerValue="Choose a Role"
                                  list="roles"
                                  listKey="id"
                                  listValue="descripcion"
                                  value="%{comiteDocencia.contactPersons[#stat.index].role.id}"
                                  cssClass="required"
                                  theme="simple">
                        </s:select>
                    </TH>
                    <TH><s:textfield name="comiteDocencia.contactPersons[%{#stat.index}].degree" value="%{comiteDocencia.contactPersons[#stat.index].degree}" theme="simple" cssClass="required"/></TH>
                    <TH><s:textfield name="comiteDocencia.contactPersons[%{#stat.index}].email" value="%{comiteDocencia.contactPersons[#stat.index].email}" theme="simple" cssClass="required"/></TH>
                    <TH><s:textfield name="comiteDocencia.contactPersons[%{#stat.index}].fax" value="%{comiteDocencia.contactPersons[#stat.index].fax}" theme="simple" cssClass="required"/></TH>
                    <TH><s:textfield name="comiteDocencia.contactPersons[%{#stat.index}].phone" value="%{comiteDocencia.contactPersons[#stat.index].phone}" theme="simple" cssClass="required"/></TH>
                    <TH><a onclick="deleteRow('table_content', this)"><img src="<s:url value="/images/delete2.png"/>" alt="Delete"></a></TH>
                </TR>
            </s:iterator>
        </s:else>
        </tbody>
    </TABLE>

    <TH><a onclick="addRowCommitee('table_content')"><img src="<s:url value="/images/add2.png"/>" alt="Add Row"></a></TH>
    <br><br>
    
    <tr>
        <td>
        <s:submit value="Save" id="save" action="save" onclick="beforeSave();beforeSaveTeachingCommittee();validate();" theme="simple"/>
        </td>
        <s:if test="%{comiteDocencia.id != null}">

        </s:if>
    </tr>
</s:form>

<s:if test="%{comiteDocencia.id != null}">
    <s:include value="../contact/List.jsp"/>
</s:if>


<script type="text/javascript">
    $("#otherCity").parent().parent().hide();
</script>

<script type="text/javascript">
    $('#teaching').css({"color":"#EE5102","fontWeight":"bold"});
</script>
